Ext.namespace("NewCustomer");

NewCustomer.ToFeedback = function() {
	this.winView = null;
	
	this.storeType  = new Ext.data.ArrayStore({
        	fields: ['value', 'name'],
        	data: OMS.ISSUE_TYPE2
    });
	this.txtIssueType = new Ext.form.ComboBox({
		width: 150,
		name:'issueType',
		store: this.storeType,
        valueField: 'value',
        displayField: 'name',
        editable: false,
        selectOnFocus: true
	});
	this.dtStart = new Ext.form.DateField({
		width: 85,
		name : 'issueDateFm',
		format: 'Y-m-d'
	});
	this.dtEnd = new Ext.form.DateField({
		width: 85,
		name : 'issueDateTo',
		format: 'Y-m-d'
	});
    this.btnSearch = new Ext.Toolbar.Button({
        iconCls: 'icon-search',
        text: 'æ¥æ¾',
        tooltip: {text: 'æ¥æ¾åé®é¢'},
        handler: this.queryIssue,
        scope: this
    });
		
	this.store = new Ext.data.JsonStore({
	    url: '../superviseIssue/toFeedbackIssue.form?timesnap=' + Date.parse(new Date()),
	    root: 'result',
	    totalProperty: 'total',
        remoteSort: true,
	    fields: ['superviseId','superviseType','workId','importantFlag','superviseState',
        	'closeFlag','createId','managerId','createTime','inspectorId','inspectorName',
        	'dispatchDate','feedback','fulfill','completeDate','notion','managerName',
        	'superviseTitle','superviseContent','issueType','issueDate','instancyLevel',
        	'reportDept','superviseTime','submitTime','deptId','docNum','docDispatchDeptId',
        	'auditor','receiveDeptId','origin','auditDate',
        	'deptName','reportDeptName','createName','dispatchDeptName','receiveDeptName'
        ]
	});
	//this.store.setDefaultSort('DocId', 'desc');
	this.renderType = function(value){
		return OMS.ISSUE_TYPE[value];
	};
	this.renderLevel = function(value){
		return OMS.ISSUE_LEVEL[value];
	};
	this.renderStatus = function(value){
		return OMS.SUPERVISE_STATE[value];
	};
	this.column = [
		{header: 'ç£åID', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'superviseId'},
		{header: 'ç£åç±»å', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'superviseType'},
		{header: 'é®é¢æ é¢', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'superviseTitle'},
		{header: 'è¥ä¸åID', sortable: true, align: 'center',width: 20,hidden:true,hidden:true,dataIndex: 'deptId'},
		{header: 'è¥ä¸å', sortable: true, align: 'center',width: 20,dataIndex: 'deptName'},
		{header: 'é®é¢ç±»å', sortable: true, align: 'center',width: 20,dataIndex: 'issueType',renderer:this.renderType},		
		{header: 'ç´§æ¥ç¨åº¦', sortable: true, align: 'center',width: 20,dataIndex: 'instancyLevel',renderer:this.renderLevel},
		{header: 'æåºæ¶é´', sortable: true, align: 'right',width: 20,dataIndex: 'issueDate'},
		{header: 'åå»ºäººID', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'createId'},
		{header: 'åå»ºäºº', sortable: true, align: 'center',width: 20,dataIndex: 'createName'},
		{header: 'é®é¢ç¶æ', sortable: true, align: 'center',width: 20,dataIndex: 'superviseState',renderer:this.renderStatus},
		{header: 'å·¥ä½ID', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'workId'},
		{header: 'å·²è½¬éè¦é®é¢', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'importantFlag'},
		{header: 'å½æ¡£æ å¿', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'closeFlag'},
		{header: 'ç£åè´è´£äººID', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'managerId'},
		{header: 'åå»ºæ¶é´', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'createTime'},
		{header: 'éå¤äººid', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'inspectorId'},
		{header: 'éå¤äººåç§°', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'inspectorName'},
		{header: 'ä»»å¡æ´¾åæ¶é´', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'dispatchDate'},
		{header: 'åé¦æåµ', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'feedback'},
		{header: 'è½å®æåµ', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'fulfill'},
		{header: 'å®ææé', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'completeDate'},
		{header: 'é¢å¯¼äººæ¹ç¤ºæè§', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'notion'},
		{header: 'ç£åè´è´£äºº', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'managerName'},		
		{header: 'é®é¢æè¿°', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'superviseContent'},
		{header: 'é¨é¨éæ©', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'reportDept'},
		{header: 'è´£ä»»é¨é¨', sortable: true, align: 'center',width: 20,dataIndex: 'reportDeptName'},	
		{header: 'ç£åæ¶é´', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'superviseTime'},
		{header: 'æäº¤æ¶é´', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'submitTime'},		
		{header: 'å¬æç¼å·', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'docNum'},
		{header: 'åæé¨é¨ID', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'docDispatchDeptId'},
		{header: 'æ¹ç¤ºäºº', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'auditor'},
		{header: 'æ¶æé¨é¨ID', sortable: true, align: 'center',width: 20,hidden:true,dataIndex: 'receiveDeptId'},
		{header: 'æ¥æº', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'origin'},
		{header: 'æ¹ç¤ºæ¶é´', sortable: true, align: 'right',width: 20,hidden:true,dataIndex: 'auditDate'}
	];
			
	NewCustomer.ToFeedback.superclass.constructor.call(this, {
		title: 'è½å®ä¸­åé®é¢',
        region: 'center',
        cm: new Ext.grid.ColumnModel(this.column),
        sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
        tbar: ['->','é®é¢ç±»å:', this.txtIssueType, 
		          'æé®æ¶é´:', this.dtStart, '~', this.dtEnd,this.btnSearch],
        bbar:new Ext.PagingToolbar({
			 pageSize: 15,
	         store: this.store,
	         displayInfo: true,
	         displayMsg: 'æ¾ç¤ºç¬¬ {0} æ¡å° {1} æ¡è®°å½ï¼ä¸å± {2} æ¡',
	         emptyMsg: "æ²¡æè®°å½..."
		}),
        store:this.store,
        viewConfig: { forceFit: true },
        listeners:{
        	rowdblclick : this.onViewIssue,
			//render:this.queryIssue
			activate: this.queryIssue
		}
    });
};
Ext.extend(NewCustomer.ToFeedback, Ext.grid.GridPanel, {
	queryIssue:function(btn,event){
		var param={
			start : 0,
			limit : 15,
			issueDateFm:this.dtStart.getValue(),
			issueDateTo:this.dtEnd.getValue(),
			issueType:this.txtIssueType.getValue()
		};
		this.store.load({
			params:param
		});
	},
	onViewIssue:function(grid, rowIndex,e){
		if (this.winView == null) {
			this.winView = new NewCustomer.View2(this);
		}
		this.winView.show();
		this.winView.initWin(grid.store.getAt(rowIndex).data);		
	}
});
